home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 May
/
Macworld (1998-05).dmg
/
Serious Demos
/
Lasso 2.5 Test Drive
/
Lasso 2.5 CGI
/
Java
/
DBInfo
/
GBConstrainer.java
< prev
next >
Wrap
Text File
|
1997-12-12
|
2KB
|
59 lines
import java.awt.*;
// not finished. For now, just use the static methods
public class GBConstrainer
{
protected Container mCont = null;
protected GBConstrainer(Container c)
{ mCont = c; }
public static void constrain(Container cont, Component component, int grid_y, int grid_x)
{
constrain(cont, component, grid_y, grid_x, 1, 1,
1, 1, 1, 1, true, GridBagConstraints.NORTHWEST);
}
public static void constrain(Container cont, Component component, int grid_y, int grid_x,
int cell_width, int cell_height, boolean grow)
{
constrain(cont, component, grid_y, grid_x, cell_width, cell_height,
1, 1, 1, 1, grow, GridBagConstraints.NORTHWEST);
}
public static void constrain(Container cont, Component component, int grid_y, int grid_x,
int cell_width, int cell_height, boolean grow, int wa)
{
constrain(cont, component, grid_y, grid_x, cell_width, cell_height,
1, 1, 1, 1, grow, wa);
}
public static void constrain(Container cont, Component component, int grid_y, int grid_x,
int cell_width, int cell_height,
int top, int left, int bottom, int right, boolean grow)
{
constrain(cont, component, grid_y, grid_x, cell_width, cell_height,
top, left, bottom, right, grow, GridBagConstraints.NORTHWEST);
}
public static void constrain(Container cont, Component component, int grid_y, int grid_x,
int cell_width, int cell_height,
int top, int left, int bottom, int right, boolean grow, int pos)
{
GridBagConstraints c =new GridBagConstraints();
c.gridx = grid_x;
c.gridy = grid_y;
c.gridwidth = cell_width;
c.gridheight = cell_height;
if (grow)
c.fill = GridBagConstraints.BOTH;
else
c.fill = GridBagConstraints.NONE;
c.anchor = pos;
c.weightx = c.weighty = 0.0;
if (top + left + bottom + right > 0)
c.insets = new Insets(top, left, bottom, right);
((GridBagLayout)cont.getLayout()).setConstraints(component, c);
cont.add(component);
}
}